﻿using System;
using System.Collections.Generic;
using System.Web;

namespace FDeal
{
    public class LoaiDealBUS
    {
        private LoaiDealDAO _dDAO;

        public LoaiDealBUS()
        {
            _dDAO = new LoaiDealDAO();
        }

        public void Insert(LoaiDealDTO obj)
        {
            _dDAO.insert(obj);
        }

        public void Insert( string idhinhthuc,string idloaideal,string tenloai)
        {
            LoaiDealDTO obj = new LoaiDealDTO();

            obj.Idhinhthuc = idhinhthuc;
            obj.Idloaideal = idloaideal;
            obj.Tenloai = tenloai;

            this.Insert(obj);
        }

        public void Delete(string idDeal)
        {
            _dDAO.delete(idDeal);
        }

        public void Update(LoaiDealDTO obj)
        {
            _dDAO.update(obj);
        }

        public LoaiDealDTO[] GetDsLoaiDeal()
        {
            return _dDAO.getDsLoaiDeal();
        }

        public LoaiDealDTO GetLoaiDeal(string idLoaiDeal)
        {
            LoaiDealDTO[] ds = this.GetDsLoaiDeal();

            for (int i = 0; i < ds.Length; i++)
            {
                if (ds[i].Idloaideal.Equals(idLoaiDeal))
                    return ds[i];
            }
            return null;
        }
    }
}